import { request } from "@/utils";

import type { resType } from "./common";

export type channelsItemType = {
  id: number;
  name: string;
};
type channelsType = {
  channels: channelsItemType[];
};

//获取频道列表
export function getChannelsApi() {
  return request<resType<channelsType>>({
    url: "/channels",
    method: "GET",
  });
}

//获取文章列表数据
export type articlesItemType = {
  art_id: number;
  title: string;
  aut_id: string;
  comon_count: number;
  pubdate: string;
  aut_name: string;
  is_top: number;
  cover: {
    type: string;
    images: string[];
  }
};

export type articlesResType = {
  results: articlesItemType[];
  pre_timestamp: string;
};

export function getArticlesApi(params: {
  channel_id: string;
  timestamp: string;
}) {
  return request<resType<articlesResType>>({
    url: "/articles",
    method: "GET",
    params,
  });
}
